package by.grsu.coctails.db.tables;

import by.grsu.coctails.model.db.IngredientCategoryDb;
import android.content.ContentValues;
import android.database.Cursor;

public class IngredientsCategoryTable {

	public static final String NAME = "IngredientCategory";

	private static final String[] INGREDIENTS_CATEGORY_COLUMNS = { "ID",
			"Name", "Image" };

	public static final Integer ID_COLUMN_INDEX = 0;
	public static final String ID_COLUMN = INGREDIENTS_CATEGORY_COLUMNS[ID_COLUMN_INDEX];

	public static final Integer NAME_COLUMN_INDEX = 1;
	public static final String NAME_COLUMN = INGREDIENTS_CATEGORY_COLUMNS[NAME_COLUMN_INDEX];

	public static final Integer IMAGE_COLUMN_INDEX = 2;
	public static final String IMAGE_COLUMN = INGREDIENTS_CATEGORY_COLUMNS[IMAGE_COLUMN_INDEX];

	public static IngredientCategoryDb getIngredientCategory(Cursor cursor) {
		Long id = cursor.getLong(ID_COLUMN_INDEX);
		String name = cursor.getString(NAME_COLUMN_INDEX);
		String image = cursor.getString(IMAGE_COLUMN_INDEX);

		return new IngredientCategoryDb(name, image, id);
	}

	public static ContentValues getContentValues(
			IngredientCategoryDb ingredientCategory) {
		ContentValues contentValues = new ContentValues();
		contentValues.put(NAME_COLUMN, ingredientCategory.getName());
		contentValues.put(IMAGE_COLUMN, ingredientCategory.getImagePath());

		return contentValues;
	}
}
